import pymysql

from ssh_proxy_db.SSHForwarderUtil import instance_ssh_server

server_mysql = instance_ssh_server("192.168.0.36", 3305)
server_mysql.start()
db = pymysql.connect(host='127.0.0.1', user='root', passwd='db123456!', db='will_art',
                     port=server_mysql.local_bind_port)


# 根据array数组，获取用户信息
def get_users_by_ids(user_ids):
    # sql2 = "select * from user where id  in ({user_ids})".format(user_ids=', '.join("'" + item + "'" for item in user_ids))
    sql = "select id,name from user where id  in ({})".format(','.join(map(str, user_ids)))
    cusor = db.cursor()
    cusor.execute(sql)
    datas = cusor.fetchone()
    return datas


def get_user_info(user_id):
    sql = 'select * from user where id = {}'.format(user_id)
    cusor = db.cursor()
    cusor.execute(sql)
    datas = cusor.fetchone()
    return datas


users = get_user_info(1)
print(users)
